package com.unity.bh3.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.media.StringSchema;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Knife4j配置类
 */
@Configuration
public class Knife4jConfig {

    @Bean
    public OpenAPI customOpenAPI() {
        // 创建全局的User-Id请求头参数
        Parameter userIdHeader = new Parameter()
                .in("header")
                .name("User-Id")
                .description("用户ID，用于身份验证")
                .required(true)
                .schema(new StringSchema().example("1"));

        return new OpenAPI()
                .info(new Info()
                        .title("BH3游戏后端API文档")
                        .description("基于Spring Boot的Unity游戏后端服务API文档")
                        .version("1.0.0")
                        .contact(new Contact().name("开发团队").email("dev@example.com"))
                        .license(new License().name("Apache 2.0").url("https://www.apache.org/licenses/LICENSE-2.0.html")))
                .components(new Components()
                        .addParameters("User-Id", userIdHeader));
    }
}